package com.boboPlanet.dict.consume.mqconfig;

import com.boboPlanet.comm.rabbitmq.PlanetCommMQEnum;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: TODO 保存文件MQ配置
 * @Author: mis_wu
 * @Date: 2023/7/11
 * @Company planet
 **/
@Configuration
public class PlanetSaveFileConfig {

    @Bean
    public Queue saveFileQueue(){
        return new Queue(PlanetCommMQEnum.PLANET_SAVE_FILE_MQ.getQueue(),true);
    }

    @Bean
    TopicExchange saveFileExchange() {
        return new TopicExchange(PlanetCommMQEnum.PLANET_SAVE_FILE_MQ.getExchange(),true,false);
    }

    /**
     * todo:路由绑定交换机(routing-key)
     * @return Binding
     */
    @Bean
    Binding routingKey() {
        return BindingBuilder.bind(this.saveFileQueue()).to(this.saveFileExchange())
                .with(PlanetCommMQEnum.PLANET_SAVE_FILE_MQ.getRoutingKey());
    }
}
